
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 08/26/2017 09:42:56
-- Generated from EDMX file: D:\Net\DocAndCodeSource\WebAppProjects\Util.EntityFramework\Entity.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [HM.CoreDataBase];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[T_Sys_User]', 'U') IS NOT NULL
    DROP TABLE [dbo].[T_Sys_User];
GO
IF OBJECT_ID(N'[dbo].[T_Sys_Menu]', 'U') IS NOT NULL
    DROP TABLE [dbo].[T_Sys_Menu];
GO
IF OBJECT_ID(N'[dbo].[syssubscriptions]', 'U') IS NOT NULL
    DROP TABLE [dbo].[syssubscriptions];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'T_Sys_User'
CREATE TABLE [dbo].[T_Sys_User] (
    [UserId] int  NOT NULL,
    [Status] int  NULL,
    [UserName] nvarchar(50)  NULL,
    [LoginName] nvarchar(50)  NULL,
    [Password] varchar(50)  NULL,
    [Sex] int  NULL,
    [Mobile] varchar(16)  NULL,
    [LoginTime] datetime  NULL,
    [CreateId] int  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [UpdateId] int  NOT NULL,
    [UpdateTime] datetime  NOT NULL,
    [HeadPhoto] nvarchar(512)  NULL,
    [IsLock] int  NULL
);
GO

-- Creating table 'T_Sys_Menu'
CREATE TABLE [dbo].[T_Sys_Menu] (
    [MenuId] int IDENTITY(1,1) NOT NULL,
    [Status] int  NULL,
    [Title] nvarchar(64)  NULL,
    [Hierarchy] int  NULL,
    [ParentId] int  NULL,
    [Icon] nvarchar(64)  NULL,
    [Href] nvarchar(128)  NULL,
    [CreateId] int  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [UpdateId] int  NOT NULL,
    [UpdateTime] datetime  NOT NULL,
    [Queue] int  NULL
);
GO

-- Creating table 'syssubscriptions'
CREATE TABLE [dbo].[syssubscriptions] (
    [artid] int  NOT NULL,
    [srvid] smallint  NOT NULL,
    [dest_db] nvarchar(128)  NOT NULL,
    [status] tinyint  NOT NULL,
    [sync_type] tinyint  NOT NULL,
    [login_name] nvarchar(128)  NOT NULL,
    [subscription_type] int  NOT NULL,
    [distribution_jobid] binary(16)  NULL,
    [timestamp] binary(8)  NOT NULL,
    [update_mode] tinyint  NOT NULL,
    [loopback_detection] bit  NOT NULL,
    [queued_reinit] bit  NOT NULL,
    [nosync_type] tinyint  NOT NULL,
    [srvname] nvarchar(128)  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [UserId] in table 'T_Sys_User'
ALTER TABLE [dbo].[T_Sys_User]
ADD CONSTRAINT [PK_T_Sys_User]
    PRIMARY KEY CLUSTERED ([UserId] ASC);
GO

-- Creating primary key on [MenuId] in table 'T_Sys_Menu'
ALTER TABLE [dbo].[T_Sys_Menu]
ADD CONSTRAINT [PK_T_Sys_Menu]
    PRIMARY KEY CLUSTERED ([MenuId] ASC);
GO

-- Creating primary key on [artid], [srvid], [dest_db], [status], [sync_type], [login_name], [subscription_type], [timestamp], [update_mode], [loopback_detection], [queued_reinit], [nosync_type], [srvname] in table 'syssubscriptions'
ALTER TABLE [dbo].[syssubscriptions]
ADD CONSTRAINT [PK_syssubscriptions]
    PRIMARY KEY CLUSTERED ([artid], [srvid], [dest_db], [status], [sync_type], [login_name], [subscription_type], [timestamp], [update_mode], [loopback_detection], [queued_reinit], [nosync_type], [srvname] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------